﻿<?xml version="1.0" encoding="utf-8"?>
<!--
   - Jonathan
   - Created by: Jonathan Montiverdi
   - Date: 6/13/2012
   - License: http://jonathan.codeplex.com/license
  -->
<Window x:Class="Jonathan.Interface.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Commands="clr-namespace:Monti.MVVM.Commands;assembly=Monti"
        xmlns:docking="clr-namespace:Monti.Docking;assembly=Monti"
        xmlns:Logic="clr-namespace:Jonathan.Logic"
        xmlns:Interface="clr-namespace:Jonathan.Interface"
        xmlns:MontiControls="clr-namespace:Monti.Controls;assembly=Monti"
        xmlns:ac="clr-namespace:Monti.AutoComplete;assembly=Monti"
        Icon="/Jonathan;component/Images/Tetrahedron.ico"
        Title="{Binding Path=Title}"
        Height="768"
        Width="1024">

   <Commands:CommandBehaviorCollection.Behaviors>
      <Commands:CommandBehavior Event="Loaded"
                                Command="{Binding Path=LoadedCommand}" />
      <Commands:CommandBehavior Event="Closing"
                                Command="{Binding Path=ClosingCommand}" />
   </Commands:CommandBehaviorCollection.Behaviors>

   <Window.DataContext>
      <Logic:MainViewModel />
   </Window.DataContext>

   <Window.Resources>

      <DataTemplate x:Key="DataViewerTemplate">
         <Interface:DataViewer />
      </DataTemplate>
      <DataTemplate x:Key="WikiUploadTemplate"
                    DataType="{x:Type Logic:WikiUploadViewModel}">
         <Interface:WikiUpload />
      </DataTemplate>

   </Window.Resources>

   <Grid>
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="*" />
      </Grid.RowDefinitions>

      <Grid Grid.Row="0"
            Background="#EBEBEB">
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
         </Grid.ColumnDefinitions>
         
         <Grid.Resources>
            <Style TargetType="Button">
            <Setter Property="Width" Value="25px" />
            <Setter Property="Margin" Value="0,3,3,3" />
            </Style>
         </Grid.Resources>

         <Button Grid.Column="0"
                 ToolTip="Library"
                 CommandParameter="Library"
                 Command="{Binding Path=NavigationCommand}">
            <Image Source="/Jonathan;component/Images/books.png"
                   Width="16px" Height="16px" />
         </Button>
         
         <MontiControls:DropDownButton Grid.Column="2"
                                       Width="25px"
                                       ToolTip="Options and Tools"
                                       Margin="0,3,3,3">
            <Image Source="/Jonathan;component/Images/setting_tools.png"
                   Width="16px" Height="16px" />
            <MontiControls:DropDownButton.DropDown>
               <ContextMenu>
                  <MenuItem Header="Upload to Wiki"
                            CommandParameter="Uploader"
                            Command="{Binding Path=NavigationCommand}">
                     <MenuItem.Icon>
                        <Image Source="/Jonathan;component/Images/arrow_up.png"></Image>
                     </MenuItem.Icon>
                  </MenuItem>
                  <MenuItem Header="Rebuild Databases"
                            CommandParameter="Converter"
                            Command="{Binding Path=NavigationCommand}">
                     <MenuItem.Icon>
                        <Image Source="/Jonathan;component/Images/update.png"></Image>
                     </MenuItem.Icon>
                  </MenuItem>
               </ContextMenu>
            </MontiControls:DropDownButton.DropDown>
         </MontiControls:DropDownButton>

         <MontiControls:SearchTextBox Grid.Column="4"
                                      Width="150px"
                                      Margin="3"
                                      Text="{Binding Path=SearchText, UpdateSourceTrigger=PropertyChanged}"
                                      Command="{Binding Path=SearchCommand}"
                                      ac:AutoComplete.DataProvider="{Binding Path=SearchHistory}" />
      </Grid>

      <docking:DockManager Documents="{Binding Path=Documents, Mode=TwoWay}"
                           ActiveContent="{Binding Path=ActiveDockItem, Mode=TwoWay}"
                           LeftToolWindows="{Binding Path=LeftToolWindows, Mode=TwoWay}"
                           RightToolWindows="{Binding Path=RightToolWindows, Mode=TwoWay}"
                           TopToolWindows="{Binding Path=TopToolWindows, Mode=TwoWay}"
                           BottomToolWindows="{Binding Path=BottomToolWindows, Mode=TwoWay}"
                           TemplateSelector="{Binding Path=DockingTemplateSelector, Mode=TwoWay}"
                           Grid.Row="1" />

   </Grid>
</Window>